﻿using System;
using System.Collections.Generic;
namespace Base.Common {
    public static class  LoggerCache {
        private static List<ShowCache> cacheList=new List<ShowCache>();
       public static List<ShowCache> getAll() {
            List<ShowCache> list = new List<ShowCache>();
            lock(cacheList) {
                clear();
                for(int i = cacheList.Count-1;i >=0 ;i--) {
                    list.Add(cacheList[i]);
                }
            }
            return list;
         }

        static void  clear() {
           

        }
        public static bool has(String msg) {//在界面上展示20秒之后消失
            lock(cacheList){
                clear();
                for(int i=0;i<cacheList.Count;i++) {
                    ShowCache c=cacheList[i];
                    if(msg==c.Msg) {
                        return true;
                    }
                }
                cacheList.Add(new ShowCache(msg));
            }
            return false;
        }
    }
    [Serializable]
    public class ShowCache {//保存日志信息类
        public string Msg { get; set; }
        public DateTime timeTicks
        {
            get; set;
        }
        public ShowCache(string msg) {
            Msg=msg;
            timeTicks=DateTime.Now;
        }
    }
}
